#ifndef CREATE_CUBES_H
#define CREATE_CUBES_H

int create_jokers()
{
    int joker_i;
    int max_jokers;
    int joker;
    max_jokers = 1;
    int level;
    level = Levels_Count;
    while(level > 1) 
    {
        for(joker_i = 1; joker_i <= max_jokers; ++joker_i)
        {
            while(cubes[joker = rand() % CC].level > 1);
            cubes[joker].level = level;
        }
        --level;
        ++max_jokers;
    }
    return 1;
}

int create_cubes()
{
    int y; 
    int x;
    Cube_P cube;
    
    srand(0);
    
    for(y = 0; y < CCH; ++y) {
        for(x = 0; x < CCW; ++x) {
            cube = &cubes[y*CCW+x];
            cube->y = convert_y_to_center(
                CS/2+CS*2*y+TS);
            cube->x = convert_x_to_center(
                CS/2+CS*2*x+LS);
            cube->angle = rand() % 360; 
            if (cube->angle > 180) {
                cube->angle = - (360 - cube->angle);
            }
            cube->ID = y*CCW + x; 
            cube->target = 0;
            cube->enabled = 1;
            //cube->level = rand() % Levels_Count + 1;
            cube->level = 1;
            cube->state = State_Search;
            
            cube->enabled = 0;
            cube->dx = 1;
            cube->dy = 1;
            cube->ax = 0;
            cube->ay = 0;
        }
    }
    cubes[36].enabled = 1;
    cubes[37].enabled = 1;
    cubes[38].enabled = 1;
    cubes[39].enabled = 1;
    cubes[40].enabled = 1;
    
    cubes[47].enabled = 1;
    cubes[48].enabled = 1;
    cubes[49].enabled = 1;
    cubes[50].enabled = 1;
    cubes[51].enabled = 1;
    
    cubes[58].enabled = 1;
    cubes[59].enabled = 1;
    cubes[60].enabled = 1;
    cubes[61].enabled = 1;
    cubes[62].enabled = 1;
    
    //create_jokers();
    printf("Created cubes\n");
    return 1;
}


#endif
